#include "userlib.h"

void printusage(const char *name)
{
	printf("Usage: linalter <program> [arguments] \n"
	    "I will start the program, and trace it.\n");
	exit(1);
}

void startsubprocess(int argc, char *argv[])
{
	pid_t pid;
	int i;
	char *arg[argc];
	
	if(argc == 1)
		printusage(argv[0]);

	traceme();

	pid = fork();
	if(pid == -1)
		die("fork");
	else if(pid == 0)
	{
		for(i=0; i<argc-1; i++)
			arg[i] = argv[i+1];
		arg[argc-1]=0;
		if(execv(arg[0], arg)==-1){
			perror(arg[0]);
			kill(0, SIGKILL);
		}
	}
	else
	{
		traced_process = pid;
	}
}

